package com.myway.core.common;

import java.util.HashMap;


/**
 *@author 陈建海(jianh_chen)
 *@description
 *
 * 行程单申购状态

 *
 *@date 2009-7-23
 */
public enum XCDApplyStatus{

	/**
	 * 申请中

	 */
	APPLYING("APPLYING"),		
	/**
	 * 申请通过
	 */
	APPLYPASS("APPLYPASS"),		
	/**
	 * 申请被拒绝

	 */
	APPLYREJCT("APPLYREJCT"),
	/**
	 * 已处理

	 */
	COMPLETED("COMPLETED"),		
	/**
	 * 已付款

	 */
	PAID("PAID");	
	
	/**
	 * Alias name. This is the name which will be stored in database.
	 */
	private final String alias;

	/**
	 * A hash map which keep all the ticket status enum with alias name as key.
	 */
	private static HashMap<String, XCDApplyStatus> map;

	/**
	 * Construct the hash map at load time
	 */
	static {
		map = new HashMap<String, XCDApplyStatus>();
		for (XCDApplyStatus status : XCDApplyStatus.values()) {
			map.put(status.alias, status);
		}
	}

	XCDApplyStatus(String alias) {
		this.alias = alias;
	}

	@Override
	public String toString() {
		return this.alias;

	}

	public String getAlias() {
		return alias;
	}

	/**
	 * Return a <code>TicketStatus</code> object holding the value of specified alias name
	 * 
	 * @param alias
	 *            the alias name of the status
	 * 
	 * @return a <code>TicketStatus</code> object holding the value represented by the alias name
	 *         argument
	 */
	public static XCDApplyStatus valueOfAlias(String alias) {
		XCDApplyStatus status = map.get(alias);

		if (status == null) {
			throw new IllegalArgumentException("Unknown ticket status alias [" + alias + "]");
		}

		return status;
	}
}
